package sharetime.playlist.controllers;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import sharetime.playlist.domain.Playlist;
import sharetime.playlist.service.IPlaylistManager;
import sharetime.web.controllers.BaseController;

@Controller
@RequestMapping("/viewmyplaylist")
public class ViewMyPlaylistsController extends BaseController {

	@Autowired
	@Qualifier("playlistManager")
	private IPlaylistManager playlistManager;

	@RequestMapping(method = RequestMethod.GET)
	public void index(Model model, HttpServletResponse response) {
		List<Playlist> hiddenPlaylist = playlistManager
				.getHiddenPlaylist(getRemoteUserObj().getId());
		List<Playlist> unHiddenPlaylist = playlistManager
				.getUnHiddenPlaylist(getRemoteUserObj().getId());

		// model.addAttribute("hiddenPlaylist", hiddenPlaylist);
		// model.addAttribute("unHiddenPlaylist", unHiddenPlaylist);

		String[] excludeAttributes = { "*.source" };
		String[] includeAttributes = { "*.tags", "*.playlistsResources" };

		model.addAttribute("msg", "OK");
		model.addAttribute("playlists", unHiddenPlaylist);

		renderJson(response, model, excludeAttributes, includeAttributes);
	}
}
